package com.jisf.driver.entity.enumtype;

import com.alibaba.fastjson.annotation.JSONType;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Classname VisibleEnum
 * @Description TODO
 * @Date 2022/4/27 23:33
 * @Created by jisf：【429627912@qq.com】
 */
//@JSONType(serializeEnumAsJavaBean = true)
public enum VisibleEnum implements BaseEnum<VisibleEnum, Integer> {

    SHOW(0, "显示"),
    HIDE(1, "隐藏"),
    ;

//    @EnumValue
    private Integer code;

    @JsonValue
    private String name;

    VisibleEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getName() {
        return name;
    }

    public static VisibleEnum getEnum(Integer code) {
        for (VisibleEnum e : VisibleEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        return null;
    }

    public static VisibleEnum getEnum(String name){
        for (VisibleEnum e : VisibleEnum.values()) {
            if (e.getName().equals(name)) {
                return e;
            }
        }
        return null;
    }
}
